﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using GestionAutoEcole.Service.Impl;
using GestionAutoEcole.DAO.Util;
using GestionAutoEcole.DAO.Impl;
using GestionAutoEcole.DAO.Factory;
using GestionAutoEcoleCommon.Util;

namespace GestionAutoEcole.Service.Factory
{
    public class ServiceFactory : AbstractServiceFactory
    {
        private static volatile ServiceFactory instance;
        private static object syncRoot = new Object();

        private ServiceFactory() { }

        public static ServiceFactory getInstance()
        {
            if (instance == null)
            {
                lock (syncRoot)
                {
                    if (instance == null)
                        instance = new ServiceFactory();
                }
            }

            return instance;
        }

        public CoursServiceImpl getCoursServiceImpl()
        {
            CoursServiceImpl coursService = CoursServiceImpl.getInstance();
            coursService.CoursDao = DAOFactoryMaker.getDAOFactory(Constants.factoryPatternMySql).getCoursDaoImpl();
            return coursService;
        }

        public DatePermisServiceImpl getDatePermisServiceImpl()
        {
            DatePermisServiceImpl datePermisService = DatePermisServiceImpl.getInstance();
            datePermisService.DatePermisDao = DAOFactoryMaker.getDAOFactory(Constants.factoryPatternMySql).getDatePermisDaoImpl();
            return datePermisService;
        }

        public DocumentServiceImpl getDocumentServiceImpl()
        {
            DocumentServiceImpl documentService = DocumentServiceImpl.getInstance();
            documentService.DocumentDao = DAOFactoryMaker.getDAOFactory(Constants.factoryPatternMySql).getDocumentDaoImpl();
            return documentService;
        }

        public EleveServiceImpl getEleveServiceImpl()
        {
            EleveServiceImpl eleveService = EleveServiceImpl.getInstance();
            eleveService.EleveDao = DAOFactoryMaker.getDAOFactory(Constants.factoryPatternMySql).getEleveDaoImpl();
            return eleveService;
        }

        public EleveExamenServiceImpl getEleveExamenServiceImpl()
        {
            EleveExamenServiceImpl eleveExamenService = EleveExamenServiceImpl.getInstance();
            eleveExamenService.Eleve_examenDao = DAOFactoryMaker.getDAOFactory(Constants.factoryPatternMySql).getEleveExamenDaoImpl();
            return eleveExamenService;
        }

        public EmployeeServiceImpl getEmployeeServiceImpl()
        {
            EmployeeServiceImpl employeeService = EmployeeServiceImpl.getInstance();
            employeeService.EmployeeDao = DAOFactoryMaker.getDAOFactory(Constants.factoryPatternMySql).getEmployeeDaoImpl();
            return employeeService;
        }

        public ExamenServiceImpl getExamenServiceImpl()
        {
            ExamenServiceImpl examenService = ExamenServiceImpl.getInstance();
            examenService.ExamenDao = DAOFactoryMaker.getDAOFactory(Constants.factoryPatternMySql).getExamenDaoImpl();
            return examenService;
        }

        public ExaminateurServiceImpl getExaminateurServiceImpl()
        {
            ExaminateurServiceImpl examinateurService = ExaminateurServiceImpl.getInstance();
            examinateurService.ExaminateurDao = DAOFactoryMaker.getDAOFactory(Constants.factoryPatternMySql).getExaminateurDaoImpl();
            return examinateurService;
        }

        public FonctionServiceImpl getFonctionServiceImpl()
        {
            FonctionServiceImpl fonctionService = FonctionServiceImpl.getInstance();
            fonctionService.FonctionDao = DAOFactoryMaker.getDAOFactory(Constants.factoryPatternMySql).getFonctionDaoImpl();
            return fonctionService;
        }

        public LeconServiceImpl getLeconServiceImpl()
        {
            LeconServiceImpl leconService = LeconServiceImpl.getInstance();
            leconService.LeconDao = DAOFactoryMaker.getDAOFactory(Constants.factoryPatternMySql).getLeconDaoImpl();
            return leconService;
        }

        public PermisServiceImpl getPermisServiceImpl()
        {
            PermisServiceImpl permisService = PermisServiceImpl.getInstance();
            permisService.PermisDao = DAOFactoryMaker.getDAOFactory(Constants.factoryPatternMySql).getPermisDaoImpl();
            return permisService;
        }

        public VehiculeServiceImpl getVehiculeServiceImpl()
        {
            VehiculeServiceImpl vehiculeService = VehiculeServiceImpl.getInstance();
            vehiculeService.VehiculeDao = DAOFactoryMaker.getDAOFactory(Constants.factoryPatternMySql).getVehiculeDaoImpl();
            return vehiculeService;
        }

    }
}
